package com.esd.db.dao;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.esd.db.model.taskWithBLOBs;
import com.esd.db.model.workerRecord;

public interface workerRecordMapper {
	
	List<workerRecord> selectWorkerRecordLikeDownPackName(Map<String, Object> map);

	int deleteByPrimaryKey(Integer recordId);

	int insert(workerRecord record);

	int insertSelective(workerRecord record);
		
	int inserts(List<workerRecord> list);
	
	workerRecord selectByPrimaryKey(Integer recordId);

	int updateByPrimaryKeySelective(workerRecord record);

	int updateByPrimaryKey(workerRecord record);
	
	int updateBydownPackName(workerRecord record);
	
	int updateByWorkerId(Map<String, Object> map);
	
	int updateByGiveUp(Map<String, Object> map);
	
	List<workerRecord> selectDoingTask();
	
	List<workerRecord> selectAllByWorkerId(Map<String, Object> map);
	
	int selectAllCountByWorkerId(Map<String, Object> map);
	
	int selectCountByWorkerId(Map<String, Object> map);
		
	String selectDownUrlByTaskName(String taskName);
	
	int selectPkIDByTaskName(String taskName);
	
	workerRecord selectWorkerRecordByWorkerId(Integer workerId);
	
	int selectDoingTaskCountByWorkerId(Integer workerId);
	
	List<workerRecord> selectDownNameAndTimeByWorkerIdGroupByDownPackName(Integer workerId);
	
	int selectTaskCountByDownPackName(String downPackName);
	
	int selectPackStatuByDownPackName(String downPackName);
	
	List<workerRecord> selectAllByDownPackName(String downPackName);
	
	int selectPkIDByTaskId(Integer taskId);
	
	int selectFinishTaskCountByPackId(Map<String, Object> map);
	
	int selectTaskMarkTimeZeroCountByPackId(Integer packId);
	
	String selectDownPackNameByTaskName(String taskName);
	
	String  selectDownUrlByDownPackName(String downPackName);
	
	int selectDownPackNameCountByworkerIdGroupByDownPackName(Map<String, Object> map);
	
	List<workerRecord> selectDownNameAndTimeByWorkerIdPagesGroupByDownPackName(Map<String, Integer> map);
	
	Double selectTaskMarkTimeMonthByWorkerIdAndMonth(Map<String, Object> map);
	
	Double selectSUMTaskMarkTimeByPackId(Integer packId);
	
	int selectPackIdByTaskId(Integer task_id);
	
	List<Map<String, Object>> selectWorkerIdGroupByWorkerId(Map<String, Object> map);
	
	int selectWorkerIdCountGroupByWorkerId(Map<String, Object> map);
	
	List<workerRecord> selectByWorkerIdAndEffective(Map<String, Object> map);

	List<Integer> selectPackIdByDateTime(Map<String, Object> map);
	
	List<workerRecord> selectInvalidTask(Map<String, Object> map);
	
	Integer selectInvalidCountTask();
	
	int updateByInvalid(Map<String, Object> map);
	
	//下载
	int selectdownCountByWorkerIdAndDate(Map<String, Object> map);
	//未上传,未审核,合格,超时,放弃
	int selectCountByWorkerIdAndDate(Map<String, Object> map);
	
	List<Map<String, Object>> selectMoneyList(Map<String, Object> map);
	
	List<workerRecord> selectAllRowByTaskId(int taskId);
	
	Date selectTaskUploadTimeByWorkerId(int workerId);
	
	List<workerRecord> selectTaskByWorkerId(Map<String, Object> map);
	
	int updateAduitByWorkerId2(Map<String, Object> map);
	
	List<Integer> selectPackIdByDateTime2(Map<String, Object> map);
	
	List<Map<String, Object>> selectWorkerHis(Map<String, Object> map);

	int selectDoingCountByTaskId(int taskId);
	
	List<Map<String, Object>> selectForInspectorByDay(Map<String, Object> map);

	int selectForCountInspectorByDay(Map<String, Object> map);

	List<workerRecord> selectTaskForInspectorByDay(Map<String, Object> map);

	int updateAduitForInspectByDay(Map<String, Object> map);

	List<Integer> getPackIdForinspectorByPackage();

	int selectTaskCountByPackIdForInspectorByPackage(Map<String, Object> map);

	List<Map<String, Object>> selectForInspectorByPackage(Map<String, Object> map);

	int selectCountForInspectorByPackage(Map<String, Object> map);

	List<workerRecord> selectTaskForInspectorByPackage(Map<String, Object> map);

	List<Integer> selectWorkIdsByTaskId(Map<String, Object> map);

	int updateAduitForInspectByPackage(Map<String, Object> map);

	List<Map<String,Integer>> selectTaskIdsforInspectByDay(Map<String, Object> map);

	List<Integer> selectTaskIdsforInspectByPackage(Map<String, Object> map);

	List<Integer> selectTaskIdsForResetDownload(Map<String, Object> map);
	
	/**
	 * 包审核有效时间是0的直接通过审核用
	 * @param map
	 * @return
	 */
	List<Integer> selectTaskIdsforInspectByPackageAndMarkTimeIsZero(Map<String, Object> map);
	
	/**
	 * 包审核有效时间是0的直接通过审核用
	 * @param map
	 * @return
	 */
	int updateAduitForInspectByPackageAndMarkTimeIsZero(Map<String, Object> map);
	
	/**
	 * 找到已经通过按人核审的packid
	 * @return
	 */
	List<Integer> getPackageIdsForQuickInspection(Map<String, Object> map);
	
	/**
	 * 查询快速审核列表用的list 
	 */
	List<Map<String, Object>> selectForQuickInspection(Map<String, Object> map);
	
	/**
	 * 快速审核  审核页面显示任务列表
	 * @param packId
	 * @return
	 */
	List<workerRecord> selectTaskForQuickInspection(Map<String, Object> map);
	
	/**
	 * 快速审核  根据packid查找相应任务的id
	 * @param packId
	 * @return
	 */
	List<Integer> selectTaskIdsForQuickInspection(Map<String, Object> map);
	
	/**
	 * 快速审核  根据packid查找相应的workerId用于插入工资表
	 * @param packId
	 * @return
	 */
	List<Integer> selectWorkIdsByTaskIdForQuickInspection(Map<String, Object> map);

	/**
	 * 快速审核  更新审核信息
	 * @param packId
	 * @return
	 */
	int updateAduitForQuickInspection(Map<String, Object> map);
	
	/**
	 * 查询需要释放的taskId 和  recordId
	 * @param map  查询条件
	 * @return  返回的每一个map中都存放着taskId 和  recordId
	 */
	List<Map<String, Integer>> selectReleaseTask(Map<String, Object> map);
	
	/**
	 * 修改不合格计数字段   加1
	 * @param map
	 * @return  返回更新条数
	 */
	int updateUnqualifiedCountPlusOne(Map<String, Object> map);
	
	/**
	 * 不合格超过两次释放任务  ---批量更新workerRecord信息
	 * @param recordIds   workerRecord的id   List
	 * @return  更新条数
	 */
	int updateWorkerRecordForReleaseTaskByWorkerRecordIds(List<Integer> recordIds);
	
	/**
	 * 通过任务id查找任务的下载包名
	 * @param map
	 * @return
	 */
	List<String> selectDownPackNamesByTaskIds(Map<String, Object> map);
	
	/**
	 * 工作者页面显示列表 ---不合格列表
	 * @param map
	 * @return
	 */
	List<Map<String, Object>> selectShowMapListForWorkerUnqualifiedList(Map<String, Object> map);
	
	/**
	 * 工作者页面显示列表 ---下载任务列表
	 * @param map
	 * @return
	 */
	List<Map<String, Object>> selectShowMapListForWorkerDownList(Map<String, Object> map);
	
	/**
	 * 根据条件时间条件查询工作者完成任务数
	 * @param map
	 * @return
	 */
	int selectWorkerDoneTaskNumForInspectionDetail(Map<String, Object> map);
	
	/**
	 * 根据条件时间条件查询审核的详细信息
	 * @param map
	 * @return
	 */
	List<Map<String, Object>> selectDetailListForInspectionDetail(Map<String, Object> map);
	
	/**
	 * 根据不同条件查询下载次数
	 * @param params
	 * @return
	 */
	int selectInspDownloadCount(Map<String, Object> params);
	
	/**
	 * 根据条件查询对应状态下未审核任务数
	 * @return 返回未审核任务数 int
	 */
	int getUninspectorCountByTaskEffective(Map<String, Object> map);
	
	/**
	 * 根据工资计算节点的不同 获取未审核时间
	 * @param map
	 * @return
	 */
	double selectTaskMarkTimeForUninspection(Map<String, Object> map);
	
	/**
	 * 查询初审阶段未审核任务list
	 * @return
	 */
	List<Map<String, Object>> findUninspectWorkerRecordForFirstInspection();
	
	/**
	 * 审核修改任务textgrid文件更新有效时间
	 * @param taskWithBLOBs
	 * @return
	 */
	int updateModifyWorkerRecord(taskWithBLOBs taskWithBLOBs);
	
	/**
	 * 根据outBizNo查询记录信息
	 * @param outBizNo
	 * @return
	 */
	List<workerRecord> queryWorkerRecordByOutBizNo(String outBizNo);
	
	/**
	 * 查询巡审阶段未审核任务list
	 * @return
	 */
	List<Map<String, Object>> findUninspectWorkerRecordForSecondInspection();
	
	/**
	 * 更新支付宝支付字段数据  ---初审
	 * @param map
	 * @return
	 */
	int updateAlipayOutBizNoForInspectByWorker(Map<String, Object> map);

	/**
	 * 更新支付宝支付字段数据  ---巡审
	 * @param map
	 * @return
	 */
	int updateAlipayOutBizNoForInspectByDay(Map<String, Object> map);
	
	/**
	 * 更新支付宝支付字段数据   ---包审
	 * @param map
	 * @return
	 */
	int updateAlipayOutBizNoForInspectByPackage(Map<String, Object> map);
	
	/**
	 * 更新支付宝支付字段数据   ---快速审核
	 * @param map
	 * @return
	 */
	int updateAlipayOutBizNoForInspectByQuickInspection(Map<String, Object> map);
	
	/**
	 * 根据workerid 和uploadUUID查询recordId 和 taskId
	 * @param map
	 * @return
	 */
	List<Map<String, Integer>> queryWorkerRecordIdAndTaskIdByCondition(Map<String, Object> map);
	
	/**
	 * 根据recordid 更新初审有效时间为零的任务
	 * @param recordIds
	 * @return
	 */
	int updateWorkerRecordForFirstInspectionMarkTimeIsZeroByWorkerRecordIds(Map<String, Object> map);
	
	/**
	 * 查询需要被系统回收的巡审退回初审的任务数
	 * @param map
	 * @return
	 */
	int countReleaseTaskNum(Map<String, Object> map);
	
	/**
	 * 修改巡审退回初审计数字段   加1
	 * @param map
	 * @return  返回更新条数
	 */
	int updateSendbackCountPlusOne(Map<String, Object> map);
	
	/**
	 * 巡审退回初审超过修改次数释放任务
	 * @param map
	 * @return
	 */
	int inspSecondToFirstReleaseTasks(Map<String, Object> map);

	/**
	 * 巡审退回初审 更新worker record
	 * @param map
	 * @return
	 */
	int updateInspectByDaySendbackWrokerRecords(Map<String, Object> map);

	List<Map<String, Object>> querySendbackListByInspectorId(int inspectorId);

	int querySendbackListCountByInspectorId(int inspectorId);
	/**
	 * 初审查询被退任务回列表信息
	 * @param map
	 * @return
	 */
	List<workerRecord> querySendbackWorkerRecordBySendbackUUID(Map<String, Object> map);
	
	/**
	 * 更新被退回任务的状态  提交回巡审
	 * @param map
	 * @return
	 */
	int updateWorkerRecordForModifyCompleted(Map<String, Object> map);
	
	/**
	 * 查询初审修改完成列表
	 */
	List<Map<String, Object>> queryModifyCompletedList();
	
	/**
	 * 巡审查询初审修改完毕列表信息         不包含无效任务
	 * @param map
	 * @return
	 */
	List<workerRecord> queryModifyCompletedWorkerRecordBySendbackUUID(Map<String, Object> map);

	List<Map<String, Integer>> selectTaskIdsForModifyCompleted(
			Map<String, Object> map);

	int updateAlipayOutBizNoModifyCompleted(Map<String, Object> map);

	int updateAduitForModifyCompleted(Map<String, Object> map);

	List<Map<String, Object>> queryRecycledBySystemListByInspectorId(Map<String, Object> map);

	int queryRecycledBySystemListByInspectorIdCount(int inspectorId);

	List<Map<String, Object>> queryWaitingModifyList(Map<String, Object> map);

	List<Map<String, Integer>> queryReleaseTaskIdAndRecordIdBySendBackUUIDs(Map<String, Object> map);
	
	/**
	 * 根据id更新初审审核修改未完成的工作记录数据
	 * @param recordIds
	 * @return
	 */
	int updateWorkerRecordForModifyUncompletedByWorkerRecordIds(List<Integer> recordIds);

	List<Map<String, Object>> queryModifyTimeOutListByInspectorId(Map<String, Object> map);

	int queryModifyTimeOutListByInspectorIdCount(int inspectorId);

	//查询所有工作组未提交到巡审审核的所有任务的任务任务数
	List<Map<String, Object>> queryNotReturnTotal();
	//查询所有工作组中工作者未上传的任务数
	List<Map<String, Object>> queryNotReturnNotUploadNums();
	//查询所有工作组待初审审核任务数
	List<Map<String, Object>> queryNotReturnWaitInspNums();
	//查询所有工作组待初审修改任务数
	List<Map<String, Object>> queryNotReturnWaitInspModificationNums();

	int queryWaitInspModificationNumByWorkGroupCode(String workGroupCode);

	Map<String, Object> selectPkIdAndUnqualifiedCountByTaskId(int taskId);

	List<Map<String, Object>> queryTaskIdsRecordIdsAndFilesForAuditingUpdateFinalMd5(Map<String, Object> map);

	int updateFinalMd5ByRecordId(Map<String, Object> map);

	List<Map<String, Object>> queryTaskIdsRecordIdsAndFilesForInspectByDayUpdateFinalMd5(Map<String, Object> map);

	List<Map<String, Object>> queryTaskIdsRecordIdsAndFilesForInspectByPackageUpdateFinalMd5(Map<String, Object> map);

	List<Map<String, Object>> queryTaskIdsRecordIdsAndFilesForQuickInspectionPosteUpdateFinalMd5(Map<String, Object> map);
	
	/**
	 * 根据工作者id和时间查询所有下载的任务记录数
	 */
	int queryAllDownloadNumByworkerIdAndDate(Map<String, Object> map);
	/**
	 * 根据工作者id和时间查询未上传记录数
	 */
	int queryNotUploadNumByworkerIdAndDate(Map<String, Object> map);
	
	/**
	 * 根据工作者id和时间以及结算节点查询未结算记录数
	 */
	int queryNotSettlementNumByworkerIdAndDate(Map<String, Object> map);
	
	/**
	 * 根据工作者id和时间查询一次性成功数
	 */
	int queryOneTimeSuccessNumByworkerIdAndDate(Map<String, Object> map);
	
	/**
	 * 根据工作者id和时间查询 超时 记录数
	 */
	int queryOverTimeNumByworkerIdAndDate(Map<String, Object> map);
	
	/**
	 * 根据工作者id和时间查询 放弃 记录数
	 */
	int queryGiveUpNumByworkerIdAndDate(Map<String, Object> map);
	
	/**
	 * 根据工作者id和时间查询 被系统收回 记录数
	 */
	int querySystemTakeBackNumByworkerIdAndDate(Map<String, Object> map);
	
	/**
	 * 根据工作者id和时间查询 被修改过的 记录数
	 */
	int queryModifyNumByworkerIdAndDate(Map<String, Object> map);
	
	/**
	 * 根据时间查询工作者上传任务总量
	 */
	int queryUploadCountByDate(Map<String, Object> map);
	
	/**
	 * 将多次错误回收任务发送至worker939的账号中
	 */
	int copyRecordToWorker939(Map<String, Object> map);
	
	/**
	 * 根据工作组代码 上传时间用户名等信息查询上传时间等数据
	 * @param map
	 * @return Map<String,Object> map key : totleTime, workerId, realname, username
	 */
	List<Map<String, Object>> selectByWorkGroupCodeAndUploadTimeAndUsername(Map<String, Object> map);
	
	/**
	 * 根据工作者id查询已上传未审核的标注时间
	 * @param workerId
	 * @return
	 */
	double selectUninspectionTimeUploadTimeByWorkerId(Map<String, Object> map);
	
	/**
	 * 根据工作者id查询已上传已审核过的标注时间
	 * @param workerId
	 * @return
	 */
	double selectInspectedTimeUploadTimeByWorkerId(Map<String, Object> map);
	
	/**
	 * 初审修改超时任务发送至worker939的账号中
	 */
	int firstInspTimeUpCopyRecordToWorker939(Map<String, Object> m2);

	int selectWorkerIdCountGroupByWorkerIdConditionByPackBatchName(Map<String, Object> map);

	List<Map<String, Object>> selectWorkerIdGroupByWorkerIdConditionByPackBatchName(Map<String, Object> map);

	int selectWorkerDownloadTaskNumByWorkerId(int workerId);

	int updateWorkerDownloadTaskLockTimeByWorkerId(Map<String, Object> map);
	
	/**
	 * 初审审核修改有效时间为0的任务的有效时间为0.001
	 * @param map
	 * @return
	 */
	boolean updateWorkerRecordChangeZeroTo0001(Map<String, Object> map);

	
}